//抽象类shape
abstract class Shape {
    // 抽象方法
    public abstract double getArea(); // 计算面积

    public abstract double getPerimeter(); // 计算周长
}

// 圆形类Circle
class Circle extends Shape { // 继承shape类
    private double r;// 成员变量半径
    private double x; // 圆心横坐标
    private double y; // 圆心纵坐标

    // 默认无参构造方法
    protected Circle() {

    }

    protected Circle(double newr) {
        this.r = newr;
    }

    protected Circle(double newr, double newx, double newy) {
        this.r = newr;
        this.x = newx;
        this.y = newy;
    }

    // 求圆面积
    public double getArea() {
        return Math.PI * r * r;
    }

    // 求圆周长
    public double getPerimeter() {
        return Math.PI * 2 * r;
    }

}

// 矩形类Rectangle
class Rectangle extends Shape {
    private double x; // 左上角横坐标
    private double y; // 左上角纵坐标
    private double length; // 矩形长
    private double width; // 矩形宽

    // 默认无参构造
    protected Rectangle() {

    }

    protected Rectangle(double newx, double newy, double newlength, double newwidth) {
        x = newx;
        y = newy;
        length = newlength;
        width = newwidth;
    }

    // 求矩形面积
    public double getArea() {
        return length * width;
    }

    // 求矩形周长
    public double getPerimeter() {
        return 2 * (length * width);
    }
}

class test {
    public static void main(String[] args) {
        Circle c1 = new Circle(5.0, 0, 0);
        System.out.println("圆c1的面积:" + c1.getArea());
        System.out.println("圆c1的周长:" + c1.getPerimeter());

        Rectangle r1 = new Rectangle(0, 0, 5, 6);
        System.out.println("矩形r1的面积:" + r1.getArea());
        System.out.println("矩形r1的周长:" + r1.getPerimeter());
    }
}